< previous page page_44 next page >

Page 44
Some lightweight controls, such as image and label controls, do not become part of the clipping region. As a result, graphics you draw on top of those controls covers them. When you are through with the Paint event, Visual Basic refreshes these controls so that they are no longer covered by your graphics.
When ClipControls is false and a form receives a Paint event, Visual Basic does not create a clipping region. Instead, it lets you draw over any controls on the form. When the Paint event finishes, Visual Basic refreshes any controls that would not have been part of the clipping region, like image controls or labels. As a result, those kinds of controls will appear on top of your graphics, but other controls will not.
Creating and using a clipping region can be time consuming, especially if you have a lot of controls on your form. If you know that you will not draw graphics on top of controls like text boxes, which are not automatically refreshed by Visual Basic after Paint events, you should set ClipControls to false so that your program can run faster.
If you might draw graphics over text controls, you can still set ClipControls to false to make your program faster. After you have finished drawing on the form, execute the Refresh method for any controls that Visual Basic does not automatically refresh for you.
Example program ClipCtls, shown in Figure 1.26, displays three picture box controls, each containing a label, a text box, and an image control. The first picture box has ClipControls set to true. During Paint events, the graphics obscure the label and image control. The clipping region prevents the graphics from covering the text box. When the Paint event is complete, Visual Basic refreshes the label and image controls so that the graphics do not cover any of the controls.
ClipControls is false in the second picture box. During Paint events, the graphics obscure all of the controls. When the Paint event is complete, Visual Basic refreshes the label and image controls, but the text control remains covered by the graphics.
0044-01.jpg
Figure 1.26
Example program ClipCtls demonstrates the ClipControls property.

 
< previous page page_44 next page >